package com.dengqi.mymodule.activity.glide.adapter;

import android.content.Context;

import com.dengqi.mymodule.activity.glide.activity.GlideFragment;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

/**
 * FragmentPagerAdapter:只走onDestroyView
 * FragmentStatePagerAdapter走onDestroyView-onDestroy-onDetach
 * Created by dell on 2018/6/28
 */

public class FragmentViewPagerAdatper extends FragmentStatePagerAdapter {

    HashMap<Integer, GlideFragment> imgLists = new LinkedHashMap<>();
    List<String> strLists;
    Context mContext;

    public FragmentViewPagerAdatper(FragmentManager fm, Context mContext, List<String> strLists) {
        super(fm);
        this.mContext = mContext;
        this.strLists = strLists;
    }

    @Override
    public int getCount() {
        return strLists.size();
    }

    @Override
    public Fragment getItem(int position) {
        GlideFragment fragment = GlideFragment.newInstance(String.format(strLists.get(position), position + 1), "位置：" + position);
        return fragment;
    }
}
